﻿<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>可拖动的图片</title>
  <style>
    .drag{position:relative;cursor:hand}
  </style>
  <script type="text/javascript" language="JavaScript">
    var dragapproved=false;
    var z,x,y;
    //移动图片
    function move()
    {
      if (event.button==1&&dragapproved){
        z.style.pixelLeft=temp1+event.clientX-x;
        z.style.pixelTop=temp2+event.clientY-y;
        return false;
      }}
    function drags()
    {
      if (!document.all)
        return;
      if (event.srcElement.className=="drag"){
        dragapproved=true;
//以下设置拖放时的位置
        z=event.srcElement;
        temp1=z.style.pixelLeft;
        temp2=z.style.pixelTop ;
        x=event.clientX;
        y=event.clientY;
        document.onmousemove=move;    //绑定鼠标移动事件
      }}
    document.onmousedown=drags;   //绑定鼠标单击事件
    document.onmouseup=new Function("dragapproved=false");  //鼠标up事件

  </script>
</head>
<body>

<img src="LOGO1.gif" class="drag">

</body>
</html>